



// This code is a generated code by a tool
// designed and coded by Shohdi Mohamed Elsheemy ( shohdi@gmail.com )            

using System;
using System.Collections.Generic;
using System.Web;
using System.Data.Common;
using Shohdi.DataHandler;
using System.Data;




namespace DatabaseComponent
{
    
    public partial class GenderValueDB
    {
         string _Connection = "";


        public string Connection
        {
            get { return _Connection; }
            set { _Connection = value; }
        }


       
         string _Provider = "System.Data.SqlClient";

        
        public string Provider
        {
            get { return _Provider; }
            set { _Provider = value; }
        }



        public GenderValueDB()
        {
        }

        public GenderValueDB(string __Connection,params string [] __Provider)
        {

            if (__Provider.Length > 0)
                _Provider = __Provider[0];

            _Connection = __Connection;
            
        }




        public List<GenderValue> Select(ClassDataHandler con, string strTop, string strWhere, params DbParameter[] whereParams)
        {
            if (whereParams == null)
                whereParams = new DbParameter[0];

            List<GenderValue> lstRet = new List<GenderValue>();

            string strQuery = " select " + strTop  + " * from dbo.[GenderValue]  " ;

            if (strWhere != "")
            {
                strQuery = strQuery + "  " + strWhere;
            }

            DbDataReader dr = con.SelectDataReader(strQuery, CommandType.Text, whereParams);


            if (dr.HasRows)
            {
                while (dr.Read())
                {
                    GenderValue obj = new GenderValue();
 if (dr["GenderID"] != DBNull.Value)
                    {
                        obj.GenderID = (System.Boolean)dr["GenderID"];
                    }
                    else
                    {
                        obj.GenderID = false;
                    } 
 if (dr["GenderNameEN"] != DBNull.Value)
                    {
                        obj.GenderNameEN = (System.String)dr["GenderNameEN"];
                    }
                    else
                    {
                        obj.GenderNameEN = "";
                    } 
 if (dr["GenderNameAR"] != DBNull.Value)
                    {
                        obj.GenderNameAR = (System.String)dr["GenderNameAR"];
                    }
                    else
                    {
                        obj.GenderNameAR = "";
                    } 



                    lstRet.Add(obj);
                   

                }
            }

            dr.Close();


            return lstRet;
        }


        public List<GenderValue> Select(string strTop, string strWhere, params DbParameter[] whereParams)
        {
            ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);

            con.OpenConnection();

            List<GenderValue> lstRet = Select(con, strTop, strWhere, whereParams);

            con.CloseConnection();

            return lstRet;
        }

        



        public void Insert(ClassDataHandler con , GenderValue obj)
        {
            
            

                    DbParameter prmGenderID = con.createParameter();
                    prmGenderID.ParameterName = "@GenderID";
                    prmGenderID.DbType =DbType.Boolean;
                    if (obj.GenderID == null)
                    {
                        prmGenderID.Value = DBNull.Value;
                    }
                    else
                    {
                        prmGenderID.Value = obj.GenderID;
                    }
                

                    


                    DbParameter prmGenderNameEN = con.createParameter();
                    prmGenderNameEN.ParameterName = "@GenderNameEN";
                    prmGenderNameEN.DbType =DbType.String;
                    if (obj.GenderNameEN == null)
                    {
                        prmGenderNameEN.Value = DBNull.Value;
                    }
                    else
                    {
                        prmGenderNameEN.Value = obj.GenderNameEN;
                    }
                

                    


                    DbParameter prmGenderNameAR = con.createParameter();
                    prmGenderNameAR.ParameterName = "@GenderNameAR";
                    prmGenderNameAR.DbType =DbType.String;
                    if (obj.GenderNameAR == null)
                    {
                        prmGenderNameAR.Value = DBNull.Value;
                    }
                    else
                    {
                        prmGenderNameAR.Value = obj.GenderNameAR;
                    }
                

                    


           



            string strQuery = " insert into dbo.[GenderValue] ([GenderID],[GenderNameEN],[GenderNameAR]) VALUES (@GenderID,@GenderNameEN,@GenderNameAR) ; select SCOPE_IDENTITY() ";
 object scope = con.ExecuteScalar(strQuery, CommandType.Text, prmGenderID,prmGenderNameEN,prmGenderNameAR);


           

        }



        public void Insert(GenderValue obj)
        {
            ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
            con.OpenConnection();

            Insert(con,obj);


            con.CloseConnection();
        }




        public void Update(ClassDataHandler con, GenderValue obj)
        {
            
            

                    DbParameter prmGenderID = con.createParameter();
                    prmGenderID.ParameterName = "@GenderID";
                    prmGenderID.DbType =DbType.Boolean;
                    if (obj.GenderID == null)
                    {
                        prmGenderID.Value = DBNull.Value;
                    }
                    else
                    {
                        prmGenderID.Value = obj.GenderID;
                    }
                

                    


                    DbParameter prmGenderNameEN = con.createParameter();
                    prmGenderNameEN.ParameterName = "@GenderNameEN";
                    prmGenderNameEN.DbType =DbType.String;
                    if (obj.GenderNameEN == null)
                    {
                        prmGenderNameEN.Value = DBNull.Value;
                    }
                    else
                    {
                        prmGenderNameEN.Value = obj.GenderNameEN;
                    }
                

                    


                    DbParameter prmGenderNameAR = con.createParameter();
                    prmGenderNameAR.ParameterName = "@GenderNameAR";
                    prmGenderNameAR.DbType =DbType.String;
                    if (obj.GenderNameAR == null)
                    {
                        prmGenderNameAR.Value = DBNull.Value;
                    }
                    else
                    {
                        prmGenderNameAR.Value = obj.GenderNameAR;
                    }
                

                    


           



            string strQuery = " update dbo.[GenderValue] set [GenderNameEN]=@GenderNameEN,[GenderNameAR]=@GenderNameAR where  [GenderID]=@GenderID  ";

            con.ExecuteNonQuery(strQuery, CommandType.Text,prmGenderID,prmGenderNameEN,prmGenderNameAR);

            

        }


        public void Update(GenderValue obj)
        {
            ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
            con.OpenConnection();

            Update(con, obj);


            con.CloseConnection();
        }



        public void Delete(ClassDataHandler con, GenderValue obj)
        {

            

                    DbParameter prmGenderID = con.createParameter();
                    prmGenderID.ParameterName = "@GenderID";
                    prmGenderID.DbType =DbType.Boolean;
                    if (obj.GenderID == null)
                    {
                        prmGenderID.Value = DBNull.Value;
                    }
                    else
                    {
                        prmGenderID.Value = obj.GenderID;
                    }
                

                    


           



           



            string strQuery = " delete from dbo.[GenderValue]  where  [GenderID]=@GenderID  "; 
                        con.ExecuteNonQuery(strQuery, CommandType.Text,prmGenderID );  

             



        }


        public void Delete( GenderValue obj)
        {
            ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);

            con.OpenConnection();

            Delete(con, obj);

            con.CloseConnection();
        }





                    public List<GenderValue> getGenderValueByGenderID(ClassDataHandler con,System.Boolean GenderID)
                    {
                        List<GenderValue> lstRet = new List<GenderValue>();


                        DbParameter prmGenderID = con.createParameter();
                        prmGenderID.ParameterName = "@GenderID";
                        prmGenderID.DbType = DbType.Boolean;
                        if (GenderID == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmGenderID.Value = GenderID;
                        }


                        lstRet = Select(con, "" , " where [GenderID]=@GenderID ", prmGenderID);



                        return lstRet;

                    }


                    public List<GenderValue> getGenderValueByGenderID(System.Boolean GenderID)
                    {
                        List<GenderValue> lstRet = new List<GenderValue>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getGenderValueByGenderID(con, GenderID);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<GenderValue> getGenderValueByGenderNameEN(ClassDataHandler con,System.String GenderNameEN)
                    {
                        List<GenderValue> lstRet = new List<GenderValue>();


                        DbParameter prmGenderNameEN = con.createParameter();
                        prmGenderNameEN.ParameterName = "@GenderNameEN";
                        prmGenderNameEN.DbType = DbType.String;
                        if (GenderNameEN == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmGenderNameEN.Value = GenderNameEN;
                        }


                        lstRet = Select(con, "" , " where [GenderNameEN]=@GenderNameEN ", prmGenderNameEN);



                        return lstRet;

                    }


                    public List<GenderValue> getGenderValueByGenderNameEN(System.String GenderNameEN)
                    {
                        List<GenderValue> lstRet = new List<GenderValue>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getGenderValueByGenderNameEN(con, GenderNameEN);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<GenderValue> getGenderValueByGenderNameAR(ClassDataHandler con,System.String GenderNameAR)
                    {
                        List<GenderValue> lstRet = new List<GenderValue>();


                        DbParameter prmGenderNameAR = con.createParameter();
                        prmGenderNameAR.ParameterName = "@GenderNameAR";
                        prmGenderNameAR.DbType = DbType.String;
                        if (GenderNameAR == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmGenderNameAR.Value = GenderNameAR;
                        }


                        lstRet = Select(con, "" , " where [GenderNameAR]=@GenderNameAR ", prmGenderNameAR);



                        return lstRet;

                    }


                    public List<GenderValue> getGenderValueByGenderNameAR(System.String GenderNameAR)
                    {
                        List<GenderValue> lstRet = new List<GenderValue>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getGenderValueByGenderNameAR(con, GenderNameAR);

                        con.CloseConnection();

                        return lstRet;

                    }



                

            
public List<GenderValue> Search(ClassDataHandler con, GenderValue obj)
        {
            string strWhere = "";
            List<DbParameter> lstParameters = new List<DbParameter>();

            
                    if (obj.GenderID != false)
                    {
                        DbParameter prmGenderID = con.createParameter();
                        prmGenderID.ParameterName = "@GenderID";
                        prmGenderID.DbType =DbType.Boolean;
                        if (obj.GenderID == null)
                        {
                            prmGenderID.Value = DBNull.Value;
                        }
                        else
                        {
                            prmGenderID.Value = obj.GenderID;
                        }
                        strWhere += " [GenderID]=@GenderID AND ";
                        lstParameters.Add(prmGenderID);
                     }



                    

                    if (obj.GenderNameEN != "")
                    {
                        DbParameter prmGenderNameEN = con.createParameter();
                        prmGenderNameEN.ParameterName = "@GenderNameEN";
                        prmGenderNameEN.DbType =DbType.String;
                        if (obj.GenderNameEN == null)
                        {
                            prmGenderNameEN.Value = DBNull.Value;
                        }
                        else
                        {
                            prmGenderNameEN.Value = obj.GenderNameEN;
                        }
                        strWhere += " [GenderNameEN]=@GenderNameEN AND ";
                        lstParameters.Add(prmGenderNameEN);
                     }



                    

                    if (obj.GenderNameAR != "")
                    {
                        DbParameter prmGenderNameAR = con.createParameter();
                        prmGenderNameAR.ParameterName = "@GenderNameAR";
                        prmGenderNameAR.DbType =DbType.String;
                        if (obj.GenderNameAR == null)
                        {
                            prmGenderNameAR.Value = DBNull.Value;
                        }
                        else
                        {
                            prmGenderNameAR.Value = obj.GenderNameAR;
                        }
                        strWhere += " [GenderNameAR]=@GenderNameAR AND ";
                        lstParameters.Add(prmGenderNameAR);
                     }



                    


            if (strWhere != "")
                        strWhere = " where " + strWhere.Substring(0, strWhere.LastIndexOf("AND"));

                    

            

            List<GenderValue> lstRet = Select(con, "", strWhere, lstParameters.ToArray());

            return lstRet;
        }


        public List<GenderValue> Search(GenderValue obj)
        {
            ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);

            con.OpenConnection();

            List<GenderValue> lstRet = Search(con,obj);

            con.CloseConnection();

            return lstRet;
        }


                

            
public List<GenderValue> SearchOrLike(ClassDataHandler con, GenderValue obj)
        {
            string strWhere = "";
            List<DbParameter> lstParameters = new List<DbParameter>();

            
                    if (obj.GenderID != false)
                    {
                        DbParameter prmGenderID = con.createParameter();
                        prmGenderID.ParameterName = "@GenderID";
                        prmGenderID.DbType =DbType.Boolean;
                        if (obj.GenderID == null)
                        {
                            prmGenderID.Value = DBNull.Value;
                        }
                        else
                        {
                            prmGenderID.Value = obj.GenderID;
                        }
                        strWhere += " [GenderID]=@GenderID OR ";
                        lstParameters.Add(prmGenderID);
                     }



                    

                    if (obj.GenderNameEN != "")
                    {
                        DbParameter prmGenderNameEN = con.createParameter();
                        prmGenderNameEN.ParameterName = "@GenderNameEN";
                        prmGenderNameEN.DbType =DbType.String;
                        if (obj.GenderNameEN == null)
                        {
                            prmGenderNameEN.Value = DBNull.Value;
                        }
                        else
                        {
                            prmGenderNameEN.Value = obj.GenderNameEN;
                        }
                        strWhere += " [GenderNameEN] LIKE @GenderNameEN OR ";
                        lstParameters.Add(prmGenderNameEN);
                     }



                    

                    if (obj.GenderNameAR != "")
                    {
                        DbParameter prmGenderNameAR = con.createParameter();
                        prmGenderNameAR.ParameterName = "@GenderNameAR";
                        prmGenderNameAR.DbType =DbType.String;
                        if (obj.GenderNameAR == null)
                        {
                            prmGenderNameAR.Value = DBNull.Value;
                        }
                        else
                        {
                            prmGenderNameAR.Value = obj.GenderNameAR;
                        }
                        strWhere += " [GenderNameAR] LIKE @GenderNameAR OR ";
                        lstParameters.Add(prmGenderNameAR);
                     }



                    


            if (strWhere != "")
                        strWhere = " where " + strWhere.Substring(0, strWhere.LastIndexOf("OR"));

                    

            

            List<GenderValue> lstRet = Select(con, "", strWhere, lstParameters.ToArray());

            return lstRet;
        }


        public List<GenderValue> SearchOrLike(GenderValue obj)
        {
            ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);

            con.OpenConnection();

            List<GenderValue> lstRet = SearchOrLike(con,obj);

            con.CloseConnection();

            return lstRet;
        }


                
        


       
        



    }
}











            